Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In tests check for SIGTERM signal after nvimProcess.kill() #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

angrypie
Copy link

@angrypie angrypie commented Feb 13, 2025

Error is not printed before process.exit(1)

  1. Added simple timeout before process.exit(1) to make sure the error is printed before the process exits.
  2. For some reason Nvim process is exiting with code null so check for SIGTERM as well.

Alternatively we could do nvim.call('nvim_exec_lua', ['vim.cmd("quit")']) and check for 0 code.

Before

RUN  v2.1.8 /Users/el/Code/github.com/magenta.nvim

❯ node/tea/view.spec.ts (1)
  ❯ Neovim Plugin Tests (1)
    ⠧ basic rendering & update
file:///Users/el/Code/github.com/magenta.nvim/node_modules/vitest/dist/chunks/execute.2pr0rHgK.js:600
   throw new Error(`process.exit unexpectedly called with "${code}"`);
   ^

Error: process.exit unexpectedly called with "1"
   at process.exit (file:///Users/el/Code/github.com/magenta.nvim/node_modules/vitest/dist/chunks/execute.2pr0rHgK.js:600:11)
   at process.<anonymous> (/Users/el/Code/github.com/magenta.nvim/node/test/preamble.ts:194:13)
   at process.emit (node:events:530:35)
❯ node/tea/view.spec.ts (1)
  ❯ Neovim Plugin Tests (1)
    ⠏ basic rendering & update

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: Worker exited unexpectedly
❯ ChildProcess.<anonymous> node_modules/tinypool/dist/index.js:139:34
❯ ChildProcess.emit node:events:530:35
❯ ChildProcess._handle.onexit node:internal/child_process:293:12

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Test Files (1)
Tests (1)
Errors 1 error
Start at 17:27:31
Duration 651ms (transform 160ms, setup 0ms, collect 405ms, tests 0ms, environment 0ms, prepare 29ms)

After

RUN  v2.1.8 /Users/el/Code/github.com/magenta.nvim

stderr | node/tea/view.spec.ts
Error: Nvim process exited with code null and signal SIGTERM
    at ChildProcess.<anonymous> (/Users/el/Code/github.com/magenta.nvim/node/test/preamble.ts:42:15)
    at ChildProcess.emit (node:events:518:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

 ✓ node/tea/view.spec.ts (1)
   ✓ Neovim Plugin Tests (1)
     ✓ basic rendering & update

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  17:32:09
   Duration  725ms (transform 170ms, setup 0ms, collect 465ms, tests 130ms, environment 0ms, prepare 33ms)

Check for exit code as well as signal (SIGTERM)

RUN  v2.1.8 /Users/el/Code/github.com/magenta.nvim

✓ node/tea/view.spec.ts (1)
  ✓ Neovim Plugin Tests (1)
    ✓ basic rendering & update

Test Files  1 passed (1)
     Tests  1 passed (1)
  Start at  18:17:33
  Duration  605ms (transform 163ms, setup 0ms, collect 361ms, tests 127ms, environment 0ms, prepare 29ms)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant